#include<bits/stdc++.h>
using namespace std;const int N=3e5+5,M=2.3e6+5,mod=998244353;using ll=long long;
int qp(int x,int y){int res=1;while(y)res=1ll*res*(y&1?x:1)%mod,x=1ll*x*x%mod,y>>=1;return res;}
int n,m,q,p[N],f[M],g[M],h1[1505],h2[1505],inv,X[N],Y[N],ans[N];
int id(int x,int y){return (x-1)*n+y;}
void sol(){memset(g,0,sizeof(g)),memset(h1,0,sizeof(h1)),memset(h2,0,sizeof(h2));
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(i!=j)
		h1[i]=(h1[i]+f[id(i,j)])%mod,h2[j]=(h2[j]+f[id(i,j)])%mod;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(i!=j){int u=id(i,j);
		g[u]=(1ll*(n-2)*(n-3)/2%mod*inv%mod*f[u]+1ll*inv*f[id(j,i)])%mod;
		g[u]=(g[u]+inv*(h1[i]+h2[j]+2ll*(mod-f[u])))%mod;
	}memcpy(f,g,sizeof(g));
}
int ask(){int res=0;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(p[i]>p[j])res=(res+f[id(i,j)])%mod;
	return res;
}
namespace sol1{int s[N];
	void add(int u,int v){while(u)s[u]+=v,u-=u&-u;}
	int ask(int u){int res=0;while(u<=n)res+=s[u],u+=u&-u;return res;}
	int sol(){ll res=0;for(int i=1;i<=n;i++)res+=ask(p[i]),add(p[i],1);cout<<res<<"\n";return 0;}
}
int main(){freopen("random.in","r",stdin),freopen("random.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m>>q,inv=qp(1ll*n*(n-1)/2%mod,mod-2);for(int i=1;i<=n;i++)cin>>p[i];
	if(m==0)return sol1::sol();
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)f[id(i,j)]=1;
	for(int i=1;i<=q;i++)cin>>X[i]>>Y[i],swap(p[X[i]],p[Y[i]]);
	for(int i=q+1;i<=m;i++)sol();ans[q]=ask();
	for(int k=q;k;k--)swap(p[X[k]],p[Y[k]]),sol(),ans[k-1]=ask();
	for(int i=0;i<=q;i++)cout<<ans[i]<<"\n";
}
